home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 2 / Tech Arsenal 2 (Arsenal Computer).iso / clarion / commte.cla < prev    next >
Encoding:
Text File  |  1994-07-02  |  2.1 KB  |  95 lines

  1.  
  2.            PROGRAM
  3.  
  4.     MAP
  5.       Chk4Port(BYTE),BYTE
  6.     END
  7.  
  8.  
  9.     CODE
  10.  
  11.    loop i# = 1 to 4
  12.      If Chk4Port(i#)
  13.        show(i#,1,'Com Port '&i#&' Present')
  14.      else
  15.        show(i#,1,'Com Port '&i#&' Not Present')
  16.      end
  17.    end
  18.    ask()
  19.  
  20.    return
  21.  
  22.  
  23.  
  24. !***************************************************************
  25. ! Check for a communication port
  26. !
  27. !  by John T. Giles
  28. !***************************************************************
  29.  
  30. Chk4Port       FUNCTION(ComPort)
  31.  
  32. ! ***********************************************************************
  33. !
  34. ! The 8250 UART has 10 registers accessible through 7 port addresses.
  35. ! Here are their address relative to the communcation base address.  NOTE:
  36. ! the baud rate register, (DLL) and (DLH) are active only when
  37. ! the Divisor-Latch Access-Bit (DLAB) is on.  The (DLAB) is bit 7 of
  38. ! the (LCR)
  39. !
  40. !    TXT - Output data to the serial port
  41. !    RXR - Input data from the serial port
  42. !    LCR - Initialize the serial port
  43. !    IER - Controls interrupt generation
  44. !    IIR - Indentifies interrupts
  45. !    MCR - Send control signals to the modem
  46. !    LSR - Monitor the status of the serial port
  47. !    MSR - Receive status of the modem
  48. !    DLL - Low byte of baud rate divisor
  49. !    DHH - High byte of baud rate divisor
  50.  
  51. TXR        Equate(0)         ! Transmit register (WRITE)
  52. RXR        Equate(0)         ! Receive register (READ)
  53. IER        Equate(1)         ! Interrupt Enable
  54. IIR        Equate(2)         ! Interrupt ID
  55. LCR        Equate(3)         ! Line Control
  56. MCR        Equate(4)         ! Modem Control
  57. LSR        Equate(5)         ! Line Status
  58. MSR        Equate(6)         ! Modem Status
  59. DLL        Equate(0)         ! Divisor Latch Low
  60. DLH        Equate(1)         ! Divisor Latch High
  61.  
  62. Com_Base       short,dim(4)
  63.  
  64. New_iir           byte
  65. Old_iir           byte
  66.  
  67.     CODE
  68.  
  69.   Com_Base[1] = 03F8h
  70.   Com_Base[2] = 02F8h
  71.   Com_Base[3] = 03E8h
  72.   Com_Base[4] = 02E8h
  73.  
  74.   in(Com_Base[ComPort]+IIR,old_iir)
  75.   out(Com_Base[ComPort]+IIR,0C1h)
  76.  
  77.   in(Com_Base[ComPort]+IIR,new_iir)
  78.   out(Com_Base[ComPort]+IIR,old_iir)
  79.  
  80.   ! no com port
  81.   if (band(new_iir,38h))
  82.     return(0)
  83.   end
  84.  
  85.   RETURN(1)
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.